<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- Copyright © 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<title>Overview (GNU Compiler Collection (GCC) Internals)</title>

<meta name="description" content="Overview (GNU Compiler Collection (GCC) Internals)">
<meta name="keywords" content="Overview (GNU Compiler Collection (GCC) Internals)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Option-Index.html" rel="index" title="Option Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Machine-Desc.html" rel="up" title="Machine Desc">
<link href="Patterns.html" rel="next" title="Patterns">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
span:hover a.copiable-link {visibility: visible}
-->
</style>


</head>

<body lang="en">
<div class="section-level-extent" id="Overview">
<div class="nav-panel">
<p>
Next: <a href="Patterns.html" accesskey="n" rel="next">Everything about Instruction Patterns</a>, Up: <a href="Machine-Desc.html" accesskey="u" rel="up">Machine Descriptions</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h3 class="section" id="Overview-of-How-the-Machine-Description-is-Used"><span>17.1 Overview of How the Machine Description is Used<a class="copiable-link" href="#Overview-of-How-the-Machine-Description-is-Used"> &para;</a></span></h3>

<p>There are three main conversions that happen in the compiler:
</p>
<ol class="enumerate">
<li> The front end reads the source code and builds a parse tree.

</li><li> The parse tree is used to generate an RTL insn list based on named
instruction patterns.

</li><li> The insn list is matched against the RTL templates to produce assembler
code.

</li></ol>

<p>For the generate pass, only the names of the insns matter, from either a
named <code class="code">define_insn</code> or a <code class="code">define_expand</code>.  The compiler will
choose the pattern with the right name and apply the operands according
to the documentation later in this chapter, without regard for the RTL
template or operand constraints.  Note that the names the compiler looks
for are hard-coded in the compiler&mdash;it will ignore unnamed patterns and
patterns with names it doesn&rsquo;t know about, but if you don&rsquo;t provide a
named pattern it needs, it will abort.
</p>
<p>If a <code class="code">define_insn</code> is used, the template given is inserted into the
insn list.  If a <code class="code">define_expand</code> is used, one of three things
happens, based on the condition logic.  The condition logic may manually
create new insns for the insn list, say via <code class="code">emit_insn()</code>, and
invoke <code class="code">DONE</code>.  For certain named patterns, it may invoke <code class="code">FAIL</code> to tell the
compiler to use an alternate way of performing that task.  If it invokes
neither <code class="code">DONE</code> nor <code class="code">FAIL</code>, the template given in the pattern
is inserted, as if the <code class="code">define_expand</code> were a <code class="code">define_insn</code>.
</p>
<p>Once the insn list is generated, various optimization passes convert,
replace, and rearrange the insns in the insn list.  This is where the
<code class="code">define_split</code> and <code class="code">define_peephole</code> patterns get used, for
example.
</p>
<p>Finally, the insn list&rsquo;s RTL is matched up with the RTL templates in the
<code class="code">define_insn</code> patterns, and those patterns are used to emit the
final assembly code.  For this purpose, each named <code class="code">define_insn</code>
acts like it&rsquo;s unnamed, since the names are ignored.
</p>
</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Patterns.html">Everything about Instruction Patterns</a>, Up: <a href="Machine-Desc.html">Machine Descriptions</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
